package com.example.voucher.common;

public class CommonResponse {

    public static String CODE_SUCCESS = "00000";
    public static String CODE_FAIL = "99999";

    private String code;
    private String msg;
    private Object data;

    public CommonResponse(String code, String msg, Object data) {
        super();
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public CommonResponse(ResponseEnum responseEnum, Object data) {
        super();
        this.code = responseEnum.getCode();
        this.msg = responseEnum.getMsg();
        this.data = data;
    }

    public static CommonResponse success() {
        return new CommonResponse(ResponseEnum.SUCCESS, null);
    }

    public static CommonResponse success(Object obj) {
        return new CommonResponse(ResponseEnum.SUCCESS, obj);
    }

    public static CommonResponse fail() {
        return new CommonResponse(ResponseEnum.FAIL, null);
    }

    public static CommonResponse fail(ResponseEnum responseEnum) {
        return new CommonResponse(responseEnum, null);
    }

    public static CommonResponse fail(String code, String msg) {
        return new CommonResponse(code, msg, null);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
